﻿#region

using SqlSugar;
using Vin.Extension.Framework.Entities;
using Vin.Extension.SqlSugar.Attributes;

#endregion

namespace Vin.Extension.Framework.Monitor.Entities;

public enum LoginStatus
{
    None = 0,

    /// <summary>
    /// 成功
    /// </summary>
    Success = 1,

    /// <summary>
    /// 失败
    /// </summary>
    Fail = 2
}

/// <summary>
/// 登录日志
/// </summary>
[SugarIndex("index_{table}_createTime", nameof(CreateTime), OrderByType.Asc)]
[VinSqlSugarEntity("登录日志")]
public class SysLoginLog : VinBaseEntity
{
    /// <summary>
    /// 日志类型
    /// </summary>
    [SugarColumn(ColumnDescription = "日志类型")]
    public string? Type { get; set; }

    /// <summary>
    /// 登录账号
    /// </summary>
    [SugarColumn(DefaultValue = "0", ColumnDescription = "登录账号id")]
    public long? AccountId { get; set; }

    /// <summary>
    /// 登录账号
    /// </summary>
    [SugarColumn(ColumnDescription = "登录账号")]
    public string? Account { get; set; }

    /// <summary>
    /// 登录类型
    /// </summary>
    [SugarColumn(ColumnDescription = "登录类型", DefaultValue = "''")]
    public string? LoginType { get; set; }

    /// <summary>
    /// 登录信息
    /// </summary>
    [SugarColumn(ColumnDescription = "登录信息", IsJson = true, ColumnDataType = "json")]
    public object? LoginInfo { get; set; }

    /// <summary>
    /// 登录员工
    /// </summary>
    [SugarColumn(DefaultValue = "0", ColumnDescription = "登录用户id")]
    public long? UserId { get; set; }

    /// <summary>
    /// 登录员工
    /// </summary>
    [SugarColumn(DefaultValue = "''", ColumnDescription = "登录用户")]
    public string? UserName { get; set; }

    /// <summary>
    /// 登录状态 1.成功 2.失败
    /// </summary>
    [SugarColumn(DefaultValue = "0", ColumnDescription = "登录状态 1.成功 2.失败")]
    public LoginStatus? Status { get; set; }

    /// <summary>
    /// 登录IP
    /// </summary>
    [SugarColumn(DefaultValue = "''", ColumnDescription = "登录IP")]
    public string? Ip { get; set; }

    /// <summary>
    /// 登录地址
    /// </summary>
    [SugarColumn(DefaultValue = "''", ColumnDescription = "登录地址")]
    public string? Location { get; set; }

    /// <summary>
    /// 登录浏览器
    /// </summary>
    [SugarColumn(DefaultValue = "''", ColumnDescription = "登录浏览器")]
    public string? Browser { get; set; }

    /// <summary>
    /// 登录操作系统
    /// </summary>
    [SugarColumn(DefaultValue = "''", ColumnDescription = "登录操作系统")]
    public string? Os { get; set; }

    /// <summary>
    /// 登录代理
    /// </summary>
    [SugarColumn(ColumnDataType = "text", ColumnDescription = "登录代理")]
    public string? UserAgent { get; set; }

    /// <summary>
    /// 提示消息
    /// </summary>
    [SugarColumn(DefaultValue = "''", ColumnDescription = "提示消息")]
    public string? Msg { get; set; }
}